﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Spaanjaars.ContactManager.Model.Validation;

namespace Spaanjaars.ContactManager.Model
{
    public class ContactPersonValidator : FluentValidationAdapterBase<ContactPerson>
    {
        public ContactPersonValidator()
        {
            RuleFor(contactPerson => contactPerson.Name).NotNull().WithMessage("Please specify a name");            
            RuleFor(contactPerson => contactPerson.DateOfBirth).NotNull().WithMessage("Please specify a date of birth");
            RuleFor(contactPerson => contactPerson.DateOfBirth).GreaterThan(DateTime.MinValue).WithMessage("Date of birth cannot be in the past");

            RuleFor(contactPerson => contactPerson.Name).SetValidator(new NameValidator());            

            // ....
            //RuleFor(customer => customer.Forename).NotEmpty().WithMessage("Please specify a first name");
            //RuleFor(customer => customer.Company).NotNull();
            //RuleFor(customer => customer.Discount).NotEqual(0).When(customer => customer.HasDiscount);
            //RuleFor(customer => customer.Address).Length(20, 250);
            //RuleFor(customer => customer.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
        }        
     }     
}
